package com.njtoyo.taxi.admin.rest.controller.data;

import com.njtoyo.taxi.admin.aop.PermissionScope;
import com.njtoyo.taxi.admin.rest.presenter.data.data_analysis.RecommendChartPresenter;
import com.njtoyo.taxi.admin.rest.wrapper.data.chart.ChartQueryWrapper;
import com.njtoyo.taxi.admin.service.data.*;
import com.njtoyo.taxi.entity.backend.AdminUser;
import com.taxi.entity.common.RestResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;

@RequestMapping("/data/chart")
@Api(value = "趋势图", tags = "趋势图")
@RestController
public class ChartController {

    @Autowired
    private OrderService orderService;

    @Autowired
    private IncomeService incomeService;

    @Autowired
    private RecommendService recommendService;

    @Autowired
    private CallService callService;

    @Autowired
    private WorkingTaxiService workingTaxiService;

    @GetMapping("/order")
    @ApiOperation(value = "订单趋势图", notes = "权限：data_analysis_rank_list")
    @PermissionScope(names = {"data_analysis_rank_list"})
    public RestResult order(@ApiIgnore @ModelAttribute("admin") AdminUser adminUser, ChartQueryWrapper wrapper) {
        return orderService.chart(adminUser, wrapper);
    }

    @GetMapping("/income")
    @ApiOperation(value = "收入趋势图", notes = "权限：data_analysis_rank_list")
    @PermissionScope(names = {"data_analysis_rank_list"})
    public RestResult income(@ApiIgnore @ModelAttribute("admin") AdminUser adminUser, ChartQueryWrapper wrapper) {
        return incomeService.chart(adminUser, wrapper);
    }

    @GetMapping("/no_response")
    @ApiOperation(value = "无应答趋势图", notes = "无应答的数据没有公司筛选项，权限：data_analysis_rank_list")
    @PermissionScope(names = {"data_analysis_rank_list"})
    public RestResult noResponse(@ApiIgnore @ModelAttribute("admin") AdminUser adminUser, ChartQueryWrapper wrapper) {
        return orderService.noResponseChart(adminUser, wrapper);
    }

    @GetMapping("/recommend")
    @ApiOperation(value = "推广量趋势图", notes = "权限：data_analysis_rank_list")
    @PermissionScope(names = {"data_analysis_rank_list"})
    public RestResult<List<RecommendChartPresenter>> recommend(@ApiIgnore @ModelAttribute("admin") AdminUser adminUser, ChartQueryWrapper wrapper) {
        return recommendService.chart(adminUser, wrapper);
    }

    @GetMapping("/call")
    @ApiOperation(value = "呼叫趋势图", notes = "呼叫数据没有公司筛选项，权限：data_analysis_rank_list")
    @PermissionScope(names = {"data_analysis_rank_list"})
    public RestResult call(@ApiIgnore @ModelAttribute("admin") AdminUser adminUser, ChartQueryWrapper wrapper) {
        return callService.chart(adminUser, wrapper);
    }

    // todo
//    @GetMapping("/working_taxi_count")
//    @ApiOperation(value = "出车数趋势图", notes = "权限：data_analysis_rank_list")
//    @PermissionScope(names = {"data_analysis_rank_list"})
//    public RestResult<List<WorkingTaxiCountChartPresenter>> workingTaxiCount(@ApiIgnore @ModelAttribute("admin") AdminUser adminUser, ChartQueryWrapper wrapper) {
//        return workingTaxiService.chart(adminUser, wrapper);
//    }
}
